Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.default = void 0;

var t = {}, n = /d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g, e = "[^\\s]+", r = /\[([^]*?)\]/gm, u = function() {};

function o(t, n) {
    for (var e = [], r = 0, u = t.length; r < u; r++) e.push(t[r].substr(0, n));
    return e;
}

function a(t) {
    return function(n, e, r) {
        var u = r[t].indexOf(e.charAt(0).toUpperCase() + e.substr(1).toLowerCase());
        ~u && (n.month = u);
    };
}

function i(t, n) {
    for (t = String(t), n = n || 2; t.length < n; ) t = "0" + t;
    return t;
}

var s = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], d = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], m = o(d, 3), c = o(s, 3);

t.i18n = {
    dayNamesShort: c,
    dayNames: s,
    monthNamesShort: m,
    monthNames: d,
    amPm: [ "am", "pm" ],
    DoFn: function(t) {
        return t + [ "th", "st", "nd", "rd" ][t % 10 > 3 ? 0 : (t - t % 10 != 10) * t % 10];
    }
};

var f = {
    D: function(t) {
        return t.getDate();
    },
    DD: function(t) {
        return i(t.getDate());
    },
    Do: function(t, n) {
        return n.DoFn(t.getDate());
    },
    d: function(t) {
        return t.getDay();
    },
    dd: function(t) {
        return i(t.getDay());
    },
    ddd: function(t, n) {
        return n.dayNamesShort[t.getDay()];
    },
    dddd: function(t, n) {
        return n.dayNames[t.getDay()];
    },
    M: function(t) {
        return t.getMonth() + 1;
    },
    MM: function(t) {
        return i(t.getMonth() + 1);
    },
    MMM: function(t, n) {
        return n.monthNamesShort[t.getMonth()];
    },
    MMMM: function(t, n) {
        return n.monthNames[t.getMonth()];
    },
    YY: function(t) {
        return i(String(t.getFullYear()), 4).substr(2);
    },
    YYYY: function(t) {
        return i(t.getFullYear(), 4);
    },
    h: function(t) {
        return t.getHours() % 12 || 12;
    },
    hh: function(t) {
        return i(t.getHours() % 12 || 12);
    },
    H: function(t) {
        return t.getHours();
    },
    HH: function(t) {
        return i(t.getHours());
    },
    m: function(t) {
        return t.getMinutes();
    },
    mm: function(t) {
        return i(t.getMinutes());
    },
    s: function(t) {
        return t.getSeconds();
    },
    ss: function(t) {
        return i(t.getSeconds());
    },
    S: function(t) {
        return Math.round(t.getMilliseconds() / 100);
    },
    SS: function(t) {
        return i(Math.round(t.getMilliseconds() / 10), 2);
    },
    SSS: function(t) {
        return i(t.getMilliseconds(), 3);
    },
    a: function(t, n) {
        return t.getHours() < 12 ? n.amPm[0] : n.amPm[1];
    },
    A: function(t, n) {
        return t.getHours() < 12 ? n.amPm[0].toUpperCase() : n.amPm[1].toUpperCase();
    },
    ZZ: function(t) {
        var n = t.getTimezoneOffset();
        return (n > 0 ? "-" : "+") + i(100 * Math.floor(Math.abs(n) / 60) + Math.abs(n) % 60, 4);
    }
}, h = {
    D: [ "\\d\\d?", function(t, n) {
        t.day = n;
    } ],
    Do: [ "\\d\\d?" + e, function(t, n) {
        t.day = parseInt(n, 10);
    } ],
    M: [ "\\d\\d?", function(t, n) {
        t.month = n - 1;
    } ],
    YY: [ "\\d\\d?", function(t, n) {
        var e = +("" + new Date().getFullYear()).substr(0, 2);
        t.year = "" + (n > 68 ? e - 1 : e) + n;
    } ],
    h: [ "\\d\\d?", function(t, n) {
        t.hour = n;
    } ],
    m: [ "\\d\\d?", function(t, n) {
        t.minute = n;
    } ],
    s: [ "\\d\\d?", function(t, n) {
        t.second = n;
    } ],
    YYYY: [ "\\d{4}", function(t, n) {
        t.year = n;
    } ],
    S: [ "\\d", function(t, n) {
        t.millisecond = 100 * n;
    } ],
    SS: [ "\\d{2}", function(t, n) {
        t.millisecond = 10 * n;
    } ],
    SSS: [ "\\d{3}", function(t, n) {
        t.millisecond = n;
    } ],
    d: [ "\\d\\d?", u ],
    ddd: [ e, u ],
    MMM: [ e, a("monthNamesShort") ],
    MMMM: [ e, a("monthNames") ],
    a: [ e, function(t, n, e) {
        var r = n.toLowerCase();
        r === e.amPm[0] ? t.isPm = !1 : r === e.amPm[1] && (t.isPm = !0);
    } ],
    ZZ: [ "[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z", function(t, n) {
        var e, r = (n + "").match(/([+-]|\d\d)/gi);
        r && (e = 60 * r[1] + parseInt(r[2], 10), t.timezoneOffset = "+" === r[0] ? e : -e);
    } ]
};

h.dd = h.d, h.dddd = h.ddd, h.DD = h.D, h.mm = h.m, h.hh = h.H = h.HH = h.h, h.MM = h.M, 
h.ss = h.s, h.A = h.a, t.masks = {
    default: "ddd MMM DD YYYY HH:mm:ss",
    shortDate: "M/D/YY",
    mediumDate: "MMM D, YYYY",
    longDate: "MMMM D, YYYY",
    fullDate: "dddd, MMMM D, YYYY",
    shortTime: "HH:mm",
    mediumTime: "HH:mm:ss",
    longTime: "HH:mm:ss.SSS"
}, t.format = function(e, u, o) {
    var a = o || t.i18n;
    if ("number" == typeof e && (e = new Date(e)), "[object Date]" !== Object.prototype.toString.call(e) || isNaN(e.getTime())) throw new Error("Invalid Date in fecha.format");
    u = t.masks[u] || u || t.masks.default;
    var i = [];
    return (u = (u = u.replace(r, function(t, n) {
        return i.push(n), "@@@";
    })).replace(n, function(t) {
        return t in f ? f[t](e, a) : t.slice(1, t.length - 1);
    })).replace(/@@@/g, function() {
        return i.shift();
    });
}, t.parse = function(e, u, o) {
    var a = o || t.i18n;
    if ("string" != typeof u) throw new Error("Invalid format in fecha.parse");
    if (u = t.masks[u] || u, e.length > 1e3) return null;
    var i = {}, s = [], d = [];
    u = u.replace(r, function(t, n) {
        return d.push(n), "@@@";
    });
    var m, c = (m = u, m.replace(/[|\\{()[^$+*?.-]/g, "\\$&")).replace(n, function(t) {
        if (h[t]) {
            var n = h[t];
            return s.push(n[1]), "(" + n[0] + ")";
        }
        return t;
    });
    c = c.replace(/@@@/g, function() {
        return d.shift();
    });
    var f = e.match(new RegExp(c, "i"));
    if (!f) return null;
    for (var l = 1; l < f.length; l++) s[l - 1](i, f[l], a);
    var M, g = new Date();
    return !0 === i.isPm && null != i.hour && 12 != +i.hour ? i.hour = +i.hour + 12 : !1 === i.isPm && 12 == +i.hour && (i.hour = 0), 
    null != i.timezoneOffset ? (i.minute = +(i.minute || 0) - +i.timezoneOffset, M = new Date(Date.UTC(i.year || g.getFullYear(), i.month || 0, i.day || 1, i.hour || 0, i.minute || 0, i.second || 0, i.millisecond || 0))) : M = new Date(i.year || g.getFullYear(), i.month || 0, i.day || 1, i.hour || 0, i.minute || 0, i.second || 0, i.millisecond || 0), 
    M;
};

var l = t;

exports.default = l;